const quickSort = (arr) => {
    if(arr.length <= 1) return arr;
    let center = Math.floor(arr.length / 2);
    let centerNum = arr.splice(center, 1)[0];
    let index = 0,left = [], right = []
    while(index < arr.length) {
        if(arr[index] < centerNum) {
            left.push(arr[index]);
        } else {
            right.push(arr[index]);
        }
        index++;
    }
    return quickSort(left).concat(centerNum, quickSort(right));
}

console.log('快速排序',quickSort([5, 2, 3, 1]));